﻿using HtmlAgilityPack;
using SPCoder.Utils;
using SPCoder.Utils.Nodes;
using SPCoder.Web.Utils.Nodes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace SPCoder.Web.Utils
{
    public class WebConnector : BaseConnector 
    {

        public WebConnector(string connectorType)
        { }

        public WebConnector()
        { }
        
        public override SPCoder.Utils.Nodes.BaseNode GetSPStructure(string siteUrl)
        {
            BaseNode rootNode = new PageNode();
            
            HtmlWeb page = new HtmlWeb();
            HtmlDocument document = page.Load(siteUrl);
            page.Get(siteUrl, "/");

            rootNode.Title = page.ResponseUri.Host.ToString();


            BaseNode my = new BaseNode();
            my.RootNode = rootNode;
            my.ParentNode = rootNode;
            my.Title = document.DocumentNode.Name;
            my.SPObject = document;
            rootNode.Children.Add(my);

            return rootNode;
            //rootNode.SPObject = site;
            //doSPWeb(site.RootWeb, rootNode, rootNode);
        }

        public override string ImagesPath
        {
            get
            {
                return null;
            }
            set
            { }
        }

        public override bool IsImagesPathLocal
        {
            get
            {
                return false;
            }
            set
            { }
        }
    }
}
